package com.abner.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * @description: 查询流程任务
 * @author: guoc
 * @createDate: 2020/9/10 13:38
 */
public class activitiTaskQuarty {


    public static void main(String[] args) {
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        TaskService taskService = defaultProcessEngine.getTaskService();
        //根据流程定义key，负责人来实现当前用户任务列表查询
//        List<Task> list =
//                taskService.createTaskQuery().processDefinitionKey("holiday").taskCandidateOrAssigned("abner").list();
        List<Task> list = taskService.createTaskQuery().processDefinitionKey("game").list();


        //列表展示
        for (Task task : list) {
            System.out.println("流程实例"+task.getProcessInstanceId());
            System.out.println("流程id"+task.getId());
            System.out.println("流程当前负责人"+task.getAssignee());
            System.out.println("流程名字"+task.getName());
        }
        /* 结果：
        流程实例2501
        流程id2505
        流程负责人guoc
        流程名字apply for leave
         */
    }

}
